package com.advitor;

import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorBigInt;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorType;

import java.util.Map;

/**
 * User: mishuai
 * Date: 2019-06-20
 * Time: 11:09
 * Des:
 */

public class PeopleCountLimit extends AbstractFunction {


    @Override
    public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
        String arg1Str1= FunctionUtils.getStringValue(arg1,env);
        //String arg2Str= FunctionUtils.getStringValue(arg2,env);
        String arg1Str= arg1.stringValue(env);
        //String arg2Str=arg2.stringValue(env);

        String aa=arg1.toString();
        AviatorType aviatorType1=arg1.getAviatorType();
        //String arg1Str=aviatorType1.name();

        AviatorType aviatorType2=arg2.getAviatorType();
        String arg2Str=aviatorType2.name();

        String key=arg1Str+arg2Str;
        System.out.println(key);
       /* AssemblePartDTO assemblePartDTO= FastJsonUtils.toBean(redisHandler.getValue(key),AssemblePartDTO.class);
        String pin=assemblePartDTO.getPin();
        if(StringUtils.isBlank(pin)){
            return new AviatorBigInt(0);
        }
        Integer limit=assemblePartDTO.getLimitPeopleCount();
        String channelId=assemblePartDTO.getChannelId();
        String token=assemblePartDTO.getToken();
        String listKey= AssembleRedisKeyUtils.getAssembleList(channelId,token);
        //人数
        boolean b= redisHandler.llen(listKey) < limit;*/
       boolean b=true;
        if(b){
            return new AviatorBigInt(1);
        }
        return new AviatorBigInt(0);
    }

    @Override
    public String getName() {
        return "limitPeopleCount";
    }
}
